{% set pypi_name = 'python-barbicanclient' %}
{% set upstream_version = upstream_version('5.0.1') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Client for the Barbican Key Management API
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('cliff') }}
BuildRequires:  {{ py3('keystoneauth1') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('requests') }}
BuildRequires:  {{ py3('requests-mock') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch
%if 0%{?suse_version}
Requires(post): update-alternatives
Requires(postun): update-alternatives
%else
# on RDO, update-alternatives is in chkconfig
Requires(post): chkconfig
Requires(postun): chkconfig
%endif

%description
This is a client for the Barbican Key Management API. This package includes a
Python library for accessing the API (the barbicanclient module), and a
command-line script (barbican).

%package -n python3-barbicanclient
Summary:        Client for the Barbican Key Management API
Requires:       {{ py3('cliff') }}
Requires:       {{ py3('keystoneauth1') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('six') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 4.10.0
%endif

%description -n python3-barbicanclient
This is a client for the Barbican Key Management API. This package includes a
Python library for accessing the API (the barbicanclient module), and a
command-line script (barbican).

This package contains the Python 3.x module.

%package -n python-barbicanclient-doc
Summary:        Documentation for OpenStack Key Management API Client
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-svg2pdfconverter') }}

%description -n python-barbicanclient-doc
Documentation for the client library for interacting with
Openstack Key Management API

%prep
%autosetup -p1 -n %{name}-%{version}
%py_req_cleanup

%build
%{py3_build}

# generate html docs
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# Remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}

%install
%{py3_install}

%check
python3 -m stestr.cli run \
    --black-regex 'barbicanclient.tests.test_barbican.WhenTestingBarbicanCLI.test_should_show_usage_with_help_flag'

%files -n python3-barbicanclient
%license LICENSE
%{python3_sitelib}/python_barbicanclient-%{version}-py?.?.egg-info
%{python3_sitelib}/barbicanclient
%{_bindir}/barbican

%files -n python-barbicanclient-doc
%doc README.rst doc/build/html
%license LICENSE

%changelog
